package com.sfd.test.service.async;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sfd.core.entity.ManyUser;
import com.sfd.test.service.ManyUserService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.Future;

/**
 * @author haden
 * @date 2022/12/2 21:40
 **/
@Service
public class AsyncManyUserService {
    @Resource
    private ManyUserService manyUserService;

    @Async("asyncExecutorWithTrace")
    public Future<Page<ManyUser>> asyncUserPage(int startYears, int endYears, int age, Integer pageNo, Integer pageSize) {
        Page<ManyUser> userPage = manyUserService.userPage(startYears, endYears, age, pageNo, pageSize);
        return new AsyncResult<>(userPage);
    }
}
